fix(check): distinguish permission-denied from boot chain failure#33
Merged
rocketman-code merged 1 commit intomainfrom Apr 15, 2026
Merged
fix(check): distinguish permission-denied from boot chain failure#33rocketman-code merged 1 commit intomainfrom
rocketman-code merged 1 commit intomainfrom
Conversation
Running `atomic-rollback check` as non-root on Fedora hits
permission-denied reading /boot/efi/EFI/fedora/grub.cfg (root-readable
only on Fedora). Before this change, the tool reported "Boot chain has
problems" and exited 1, conflating "we could not verify" with
"we found problems." Scripts relying on exit codes could not tell
apart the two.
Two semantically distinct facts now have distinct representations:
- grub.rs: new GrubContextError enum with PermissionDenied and Other
variants. The io::ErrorKind from fs::read_to_string is preserved at
the source instead of collapsing into a String.
- check.rs: new BootStatus::Inaccessible { reason, hint } variant.
verify_bootable and verify_snapshot_bootable map PermissionDenied to
Inaccessible, Other to Fail.
- main.rs Check: new match arm prints "Cannot verify boot chain:
<reason>" with hint, exits 3.
- kernel_hook.rs: treats Inaccessible as a warning (log, do not abort
kernel-install).
- rollback.rs: treats Inaccessible as Fail (abort rather than proceed
with an unverified snapshot).
- check.rs gate: treats Inaccessible as Fail (migration runs as root;
reaching this branch is unexpected and should fail safe).
Exit codes:
- 0: Pass
- 1: Fail (real boot-chain problem)
- 2: Warn (valid with warnings)
- 3: Inaccessible (could not verify; try sudo)
Verified on Fedora 43 VM: as root exits 0, as non-root exits 3 with
"permission denied reading /boot/efi/EFI/fedora/grub.cfg" and a
"Run: sudo atomic-rollback check" hint. The "Boot chain has problems"
message no longer fires for non-root.
Closes #14.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14.
Summary
Running
atomic-rollback checkas non-root on Fedora hits permission-denied reading/boot/efi/EFI/fedora/grub.cfg(root-readable only). Before this change, the tool reported "Boot chain has problems" and exited 1, conflating "cannot verify" with "found problems."Two semantically distinct facts now have distinct representations:
GrubContextError { PermissionDenied { path }, Other(String) }preservesio::ErrorKindat the sourceBootStatus::Inaccessible { reason, hint }variant distinct fromFailCheckhandler prints "Cannot verify boot chain: ..." with hint, exits 3 (new code for "could not verify")Exit codes
Scripts relying on exit codes can now tell the three failure modes apart.
Test plan
cargo build --releaseclean (build.rs drift check passes)cargo test --releaseall 23 tests passatomic-rollback checkexits 0 (Pass)atomic-rollback checkexits 3, reports "Cannot verify boot chain: permission denied reading /boot/efi/EFI/fedora/grub.cfg", hints "Run: sudo atomic-rollback check", does NOT say "Boot chain has problems"cargo run -p changelog > CHANGELOG.md, matches source-of-truth